'use strict';

var fn_login = async (ctx,next)=>{
    ctx.response.body=`<h1>登录</h1>
    <form action="/index" method="post">
    <P>name <input type="text" name="name"> </P>
    <P>password <input type="password" name="password" id=""></P>
    <P><input type="submit" value="submit"></P>
    </form>`
};

var fn_index =async (ctx,next)=>{
    let
    name = ctx.request.body.name ||'',
    password = ctx.request.body.password||'';
    if(name==='admin'&&password==='123456'){
        ctx.response.body=`登陆成功`
    }else{
        ctx.response.body=`
        <p>登陆失败</p>
        <p><a href="/">返回登陆</a> </p>
        `
    }
};

module.exports={
    'get /':fn_login,
    'post /index':fn_index
};